From 57dde9ed01605556ff473ac349071e159a6480c1 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 4 Jun 2009 10:43:44 +0100 Subject: [PATCH] xm: pass-through: sort the output of xm pci-list Other than being arguably more human readable, this patch reconciles the output differences between using Xen API and xmlrpc to manipulate domains. Signed-off-by: Simon Horman --- tools/python/xen/util/pci.py | 4 ++++ tools/python/xen/xm/main.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/tools/python/xen/util/pci.py b/tools/python/xen/util/pci.py index 2af8b18c5a..be7ab7108e 100644 --- a/tools/python/xen/util/pci.py +++ b/tools/python/xen/util/pci.py @@ -114,6 +114,10 @@ PAGE_MASK=~(PAGE_SIZE - 1) def PCI_DEVFN(slot, func): return ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +def PCI_BDF(domain, bus, slot, func): + return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) | + PCI_DEVFN(slot, func)) + def serialise_pci_opts(opts): return reduce(lambda x, y: x+','+y, map(lambda (x, y): x+'='+y, opts)) diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 185c304028..bea552452e 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -2205,6 +2205,9 @@ def xm_pci_list(args): if len(devs) == 0: return + devs.sort(None, lambda x: x['vslot'] << 32 | PCI_BDF(x['domain'], x['bus'], + x['slot'], x['func'])) + has_vslot = False for x in devs: if x['vslot'] == AUTO_PHP_SLOT: -- 2.30.2